Label:command-line debugging tools in a UNIX environment: gdb If you need to use the GDB debugger, add the-G option to GCC. The following command section is a simplified version, such as using L instead of list and so on. 1. Basic Commands 1) Enter GDB #
What is the worst-case scenario when writing a program without a debugger? When compiling, kneel and pray, do not make mistakes? Call the demon with a blood sacrifice to help you run the program? Or do you want to add a printf ("test") statement between each line of code to locate the error point? As you know, it is inconvenient to write a program without using a debugger. Fortunately, debugging under Linux is still very convenient. Most of the Ides u
Most people use the IDE integrated with the debugger, but the most famous debugger in linux is the command line C/C ++ debugger GDB. However, similar to other command line tools, DGB requires some exercises to be fully mastered. Here, I will tell you the basic situation and
:
Notifies GDB to suspend execution at a specific location in the program.
Set breakpoints in a specific "location" in your program, and when that point is reached, the debugger suspends execution of the program. Where "location" can refer to various source code lines, code addresses, line numbers in source code files, or the entry of functions.
Command
Server for the GDB which allows to use J-link with GDB or any toolchain which uses GDB a s debugging interface, such as Yagarto and Sourcery g++). The GDB and gdb Server communicate via a TCP/IP connection, using the standard GDB
the shell after the crash. But now we're running through GDB, so we're not jumping out now. GDB paused our program, but still kept it in memory, giving us the opportunity to do the debugging.First, we want to know exactly where it caused the program to crash. GDB has told us through the output just now: The function objc_msgsend is the root of the curse. However
four forms:L break line-number causes the program to stop just before the specified row is executed.L break function-name causes the program to stop before entering the specified function.L break line-or-function if condition if the condition is true, the program stops when it reaches the specified row or function.L break routine-name sets a breakpoint at the entrance of the specified routine
If the progra
1. Basic command
1 Enter GDB #gdb test
Test is the program to debug, generated by GCC test.c-g-o test. Enter the back-prompt into (GDB).
2) View Source (GDB) L
The source code will be the line number hint.
If you need to see
: [root@linux:~]$ GDB TestGNU gdb (GDB) 7.6Copyright (C) 2013 Free Software Foundation, Inc.License gplv3+: GNU GPL version 3 or later This is the free software:you are and redistribute it.There is NO WARRANTY and to the extent permitted by. Type "Show copying"and "Show warranty" for details.This is GDB was configured
display source code, more convenient than using the list. At this time use the UP and DOWN ARROW keys can view the source code, want to use the command line with the up and down keys with [Ctrl]n and [Ctrl]p.
* Start GDB debug the specified program app:
$gdb app
In this way, after starting
Label:Lock threadSet scheduler-locking 1. To use this command, first compile the program with GCC-G, such as:$GCC-G test.c-o testCompile the TEST.C source program, enter the debug version of this program test 2. Debug program$GDB Test//debug executable program test$ (GDB) Start//Use program test to start runningLists the source code for the specified function, or
program} ${core file}Third, GDB common commands:1. BackTrace: Displays stack information. Abbreviated to BT.2. Frame x switches to frame x. where x is displayed in the BT command, starting with 0. 0 represents the top of the stack. Abbreviated to F.3. Up/down x Move the X-frame toward the top/bottom of the stack. When x is not entered, the default is 1.4. Print x prints x information, x can be a variable,
Http://blog.csdn.net/sunlylorn/article/details/6788768
GDB user-defined commands are very useful. You can use user-defined commands to directly operate the data in the container and conveniently view the data in the STL container.
This link dbinit_stl_views is a custom command written by Dan C Marinescu to view STL containers (you can modify it if it is not suitable for your STL version ). Add it to
Process ID: Ps-fu your_user_name Run GDB: Gdb(GDB) attach xxxxx ---xxxxx the subprocess process ID obtained with the PS command(GDB) Stop ---This is important, you need to pause that subprocess first, then set some breakpoints and some watch(
Tags: c blog a http int comhttp://blog.csdn.net/allenlinrui/article/details/5964046You can use the Examine command (abbreviated as x) to view the values in the memory address. The syntax for the x command is as follows:X/N, F, and u are optional parameters.n is a positive integer that represents the number of memory units that need to be displayed, that is, the contents of several memory units are displayed
In the Linux system there are many command programs to assist the normal and convenient operation of the system, then there is a system called the GDB command program, then we today to understand the knowledge of the GDB command!
First, the general debugging
In the Linux system there are many command programs to assist the normal and convenient operation of the system, then there is a system called the GDB command program, then we today to understand the knowledge of the GDB command!
First, the general debugging
GDB Main launches GDB(GDB) L is equivalent to list, starting from the first line to list the source code(GDB) Break 16 set breakpoints, set breakpoints on line 16th of source code(GDB)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.